﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ForzaGT3.Data
{
    public partial class Language
    {
        public void Insert()
        {
            DataRepositoryFactory.CurrentRepository
                .Create<Language>(this);
        }

        public void Update()
        {
            DataRepositoryFactory.CurrentRepository
                .Modify<Language>(this);
        }

        public void Delete()
        {
            DataRepositoryFactory.CurrentRepository
                .Delete<Language>(this);
        }

        public static Language GetById(Guid Id)
        {
            return DataRepositoryFactory.CurrentRepository
                .Single<Language>(x => x.LanguageId == Id);
        }

        public static Language GetByCode(String Code)
        {
            return DataRepositoryFactory.CurrentRepository
                .Single<Language>(x => x.Code == Code);
        }

        public static Language GetDefault()
        {
            return DataRepositoryFactory.CurrentRepository
                .First<Language>(x => x.IsDefault == true);
        }

        public static IEnumerable<Language> GetAll()
        {
            return DataRepositoryFactory.CurrentRepository
                .Find<Language>(x=>x.IsDeleted == false);
        }
    }
}
